package com.cxyd.client;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.EventLoop;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class ConnectionListener implements ChannelFutureListener {
    @Override
    public void operationComplete(ChannelFuture channelFuture) throws Exception {
        if (!channelFuture.isSuccess()) {
            final EventLoop loop = channelFuture.channel().eventLoop();
            loop.schedule(() -> {
                log.error("服务端链接不上，开始重连操作...");
//                    imConnection.connect(ImClientApp.HOST, ImClientApp.PORT);
            }, 3L, TimeUnit.SECONDS);
        } else {
            System.err.println("服务端链接成功...");
        }

    }
}
